package com.ksyun.campus.metaserver.domain.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Min;
import java.util.List;

/**
 * Commit write request
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CommitRequest {
    
    @NotBlank(message = "File ID cannot be blank")
    private String fileId;
    
    @Min(value = 0, message = "Size cannot be negative")
    private long size;
    
    @NotNull(message = "Blocks cannot be null")
    private List<BlockCommitInfo> blocks;
    
    private String checksum;
    
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class BlockCommitInfo {
        private int blkIdx;
        private long size;
    }
}
